<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>设置</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
        html,
        body {
            font-size: 14px;
            height: 100%;
        }

        header {
            position: fixed;
            top: 0;
            width: 100%;
            height: 75px;
            text-align: left;
            background-color: #fff;
            border-bottom: 1px solid #f2f2f2;
        }

        header .back {
            position: relative;
            margin-top: 38px;
            width: 100%;
            height: 1.5rem;
            text-align: center;
        }

        .back img {
            position: absolute;
            left: 1rem;
            width: 1.5rem;
            height: 1.5rem;
            vertical-align: middle;
        }

        main {
            padding-top: 75px;
        }

        main .settings {
            margin-top: 1rem;
            padding: 0 1rem;
        }

        .settings li {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
            padding: 1rem 0;
            background-color: #f2f2f2;
            border-radius: 0.5rem;
        }

        .settings li:last-child {
            background-color: #fff;
        }

        .settings li div img {
            width: 1.5rem;
            height: 1.5rem;
            margin: 0 0.5rem 0 1rem;
            vertical-align: middle;
        }

        .settings li img:nth-child(2) {
            width: 1rem;
            height: 1rem;
            margin-right: 1rem;
        }

        .logout {
            width: 100%;
            padding: 1rem;
            color: #fff;
            box-sizing: border-box;
            background-color: #FBB40E;
            border-radius: 0.5rem;
        }
    </style>
</head>

<body>
    <header>
        <div class="back">
            <img src="../image/icon/back.png" alt="" onclick="api.closeWin()">
            <span>设置</span>
        </div>
    </header>
    <main>
        <ul class="settings">
            <li id="changepwd">
                <div>
                    <img src="../image/icon/xgmm.png" alt="">
                    <span>修改密码</span>
                </div>
                <img src="../image/icon/right.png" alt="">
            </li>
            <li class="nav-address" page-address="notice.html">
                <div>
                    <img src="../image/icon/xttz.png" alt="">
                    <span>系统通知</span>
                </div>
                <img src="../image/icon/right.png" alt="">
            </li>
            <li class="nav-address" page-address="feedback.html">
                <div>
                    <img src="../image/icon/yjfk.png" alt="">
                    <span>意见反馈</span>
                </div>
                <img src="../image/icon/right.png" alt="">
            </li>
            <li class="nav-address aboutus" page-address="aboutus.html">
                <div>
                    <img src="../image/icon/aboutus.png" alt="">
                    <span>关于我们</span>
                </div>
                <img src="../image/icon/right.png" alt="">
            </li>
            <li>
                <button class="logout">退出登录</button>
            </li>
        </ul>

    </main>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
    apiready = function() {

    };
    $('#changepwd').click(function() {
      if(!$api.getStorage('username')) {
        api.toast({
            msg: '请先登录再进行操作',
            duration: 2000,
            location: 'bottom'
        });
      } else {
        api.openWin({
            name: 'changepassword',
            url: './changepassword.html',
        });
      }
    })

    $(".nav-address").click(function() {
        var page_path = $(this).attr("page-address");
        if (page_path) {
            api.openWin({
                name: page_path.split(".")[0],
                url: page_path,
                bounces: false
            })
        }
    })

    $('.logout').click(function() {
        var username = $api.getStorage('username');
        if (username) {
            $api.clearStorage();
            api.closeWin({
                name: 'mysetting'
            });
        } else {
          api.toast({
              msg: '请先登录再进行操作',
              duration: 2000,
              location: 'bottom'
          });
        }

    })
</script>

</html>
